package ${packageName}.service.impl;

import BeanUtil;
import cn.com.gc.core.mybatis.PageData;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.Collections;
import org.springframework.stereotype.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.gc.frame.enums.EnableStatusEnum;
import ${packageName}.service.${name}WebService;
import ${packageName}.dao.${name}WebDao;
import ${packageName}.model.${name};
import ${packageName}.vo.response.${name}ResponseVo;
/**   
 * @Title: ${name}WebServiceImpl.java
 * @Description: ${description}的业务处理服务类
 * @author ${author}
 * @date   ${newdate}
 * @version V1.0.0
 * ----------------------------------------------------------------------------
 *  modifyer    modifyTime                 comment
 *
 * ----------------------------------------------------------------------------
 *
 */
@Component("${nameLower}WebService")
public class ${name}WebServiceImpl implements ${name}WebService{
    private final static Logger logger = LoggerFactory.getLogger(${name}WebServiceImpl.class);
    @Autowired
    private ${name}WebDao  ${nameLower}WebDao;
    /**
     * @Title: 获取${description}分页信息
     * @Description:
     * @param ${nameLower} @{Link ${name}}
     * @return
     * @throw
     * @author ${author}
     * @date ${newdate}
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
    public PageData<${name}ResponseVo> get${name}Page(${name} ${nameLower}, int start, int pageSize){
        int count = ${nameLower}WebDao.countEntity(${nameLower});
        if(count == 0){
            return new PageData<${name}ResponseVo>(Collections.EMPTY_LIST,count);
        }
        List<${name}> ${nameLower}List = ${nameLower}WebDao.findPageEntity(${nameLower}, start, pageSize);
        if(${nameLower}List == null || ${nameLower}List.isEmpty()){
            return new PageData<${name}ResponseVo>(Collections.EMPTY_LIST,count);
        }
        List<${name}ResponseVo> ${nameLower}ResponseList = ${nameLower}List.stream().map(${nameLower}Response -> {
            ${name}ResponseVo ${nameLower}ResponseVo = new ${name}ResponseVo();
            BeanUtil.copyProperties(${nameLower}Response, ${nameLower}ResponseVo);
            return ${nameLower}ResponseVo;
        }).collect(Collectors.toList());
        return new PageData<${name}ResponseVo>(${nameLower}ResponseList,count);
    }
    /**
     * @Title: 获取${description}列表信息
     * @Description:
     * @param ${nameLower} @{Link ${name}}
     * @return
     * @throw
     * @author ${author}
     * @date ${newdate}
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
    public List<${name}> get${name}List(${name} ${nameLower}){
        return ${nameLower}WebDao.findEntity(${nameLower});
    }

    /**
     * @Title: 新增${description}信息
     * @Description:
     * @param ${nameLower} @{Link ${name}}
     * @return
     * @throw
     * @author ${author}
     * @date ${newdate}
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
    public void add${name}(${name} ${nameLower}){
        ${nameLower}WebDao.createEntity(${nameLower});
    }
    /**
    * @Title: 修改${description}信息
    * @Description:
    * @param ${nameLower} @{Link ${name}}
    * @return
    * @throw
    * @author ${author}
    * @date ${newdate}
    *  --------------------------------------------------------
    *  modifyer    modifyTime                 comment
    *
    *  --------------------------------------------------------
    */
    public void upd${name}(${name} ${nameLower}){
        ${nameLower}WebDao.updateEntity(${nameLower});
    }
   /**
    * @Title: 获取${description}信息
    * @Description:
    * @param id @{Link ${pkType}}
    * @return
    * @throw
    * @author ${author}
    * @date ${newdate}
    *  --------------------------------------------------------
    *  modifyer    modifyTime                 comment
    *
    *  --------------------------------------------------------
    */
    public ${name} get${name}(${pkType} id){
        ${name} ${nameLower} = new ${name}();
        ${nameLower}.set${pkUpper}(id);
        return ${nameLower}WebDao.retrieveEntity(${nameLower});
    }
    /**
     * @Title: 删除${description}信息
     * @Description:
     * @param ids @{Link ${pkType}[]}
     * @return
     * @throw
     * @author ${author}
     * @date ${newdate}
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
    public void del(${pkType}[] ids){
        ${nameLower}WebDao.del(Arrays.asList(ids));
    }
   /**
    * @Title: 启用${description}信息
    * @Description:
    * @param ids @{Link ${pkType}[]}
    * @return
    * @throw
    * @author ${author}
    * @date ${newdate}
    *  --------------------------------------------------------
    *  modifyer    modifyTime                 comment
    *
    *  --------------------------------------------------------
    */
    public void turnOn(${pkType}[] ids){
        ${nameLower}WebDao.updateEnableStatus(EnableStatusEnum.ENABLE.getIndexStr(), Arrays.asList(ids));
    }
   /**
    * @Title: 禁用${description}信息
    * @Description:
    * @param ids @{Link ${pkType}[]}
    * @return
    * @throw
    * @author ${author}
    * @date ${newdate}
    *  --------------------------------------------------------
    *  modifyer    modifyTime                 comment
    *
    *  --------------------------------------------------------
    */
    public void turnOff(${pkType}[] ids){
        ${nameLower}WebDao.updateEnableStatus(EnableStatusEnum.DISABLE.getIndexStr(), Arrays.asList(ids));
    }
}